package com.example.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.example.mapper.UserMappper;
import com.example.service.UserService;


@Controller
@EnableAutoConfiguration
public class DemoController {

	
	@Autowired
    private UserService userService;
	
	 @RequestMapping("/")
	    @ResponseBody
	    String home() {
	        return "Hello World!";
	    }
	 
	 	@RequestMapping("/test")
	    @ResponseBody
	    String test() {
		 
		// itemManage
	        return userService.getUserById(1L).getName();
	    }
	 	
	 	@RequestMapping("/page")
		public ModelAndView  searchItemManage(HttpServletRequest req,HttpServletResponse rsp) {
	 		String cpage= req.getParameter("cpage");
	 		//if(cpage.equals("")){
	 			cpage="1";
	 		//}
	 		//String totalCount= req.getParameter("totalCount");
	 			String  totalCount="1000";
	 		//}
	 		req.setAttribute("cpage",cpage);
			req.setAttribute("totalCount", totalCount);	
			System.out.println(totalCount);
			return new ModelAndView("itemManage.jsp");
		//	return "itemManage";
	 	}
}
